/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.ismaila.designPatterns.structural.composite;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Chelsea
 */
public class Composite implements Component {
 List<Component> components=new ArrayList<Component>();
 String leafList = "";
@Override
public String sayHello(){
for(Component component:components){
leafList = leafList + component.sayHello();
    
}
return leafList;
}
@Override
public String sayGoodbye(){
for(Component component:components){
leafList = leafList + component.sayGoodbye();
}
return leafList;
}
public void add(Component component){
components.add(component);
}
public void remove(Component component){
components.remove(component);
}
public List<Component>getComponents(){
return components;
}
public Component getComponent(int index){
return components.get(index);
}

    
}
